<template>
	<view class="container">
		<!-- left左侧列表 -->
		<view class="left">
			<!-- 循环遍历的 -->
			<view :class="current==index?'left_list activeList':'left_list' " @click="change(index)" v-for="(item,index) in datalist" :key="index">
				<label for="">{{item.catename}} </label>
			</view>
	
		</view>
		<!-- right右侧详细分类商品 -->
		<view class="right">
			<!-- 每一个小类 -->
			<view class="right_list" v-if="datalist.length>0">
				<!-- 商品 -->
				<view class="bottom"  v-for="(item,index) in datalist[current].children" @click="jump(item.id)":key="index">
					<view class="bottom_list">
						<!-- 每个最多显示6个 -->
						<view >
							<image :src="$host+item.img" alt="">
						</view>
						<view class="title">
							<span>{{item.catename}} </span>
						</view>
					</view>
				</view>
				
			</view>
		</view>
		
		
		
	</view>
</template>

<script>
	export default{
		data(){
			return{
				datalist:[],
				current:0
			}
		},
		async onLoad(){
			let result= await this.$http("/api/getcates")
			this.datalist=result.data.list
		},
		methods:{
			change(index){
				this.current=index
			},
			jump(id){
			uni.navigateTo({
				url:"../details/details?id="+id
			})
			}
		}
	}
</script>

<style>
	/* 导入外部的样式文件 */
	@import url("../../common/css/classify.css");
	
	/* 点击左侧导航，显示动态样式 */
	.activeList{
		border-left: 6rpx solid #f26b11;
		color: #f26b11;
	}
</style>
